﻿
namespace BLPicker.Unity
{
    using BLPicker.Factory;
    using BLPicker.OnTheFly;
    using Microsoft.Practices.Unity;

    /// <summary>
    /// Facade for BLPicker works with unity.
    /// </summary>
    public static class UnityBusinessLayerFacade
    {
        /// <summary>
        /// Generate and compile proxy, that resolves concrete business layer by business operation name using Unity dependency container.
        /// </summary>
        /// <typeparam name="TBusinessLayer">Type of business layer.</typeparam>
        /// <param name="unityContainer">Unity container for configuring business layer proxy.</param>
        /// <returns>Automatically generated and compiled proxy, that resolves concrete business layer by business operation name using Unity dependency container.</returns>
        public static TBusinessLayer GenerateProxy<TBusinessLayer>(IUnityContainer unityContainer)
        {
            UnityBusinessLayerFactory<TBusinessLayer> unityFactory = new UnityBusinessLayerFactory<TBusinessLayer>(unityContainer);

            return BusinessLayerFacade.GenerateProxy<TBusinessLayer>(unityFactory);
        }
    }
}
